package com.sgb.kjwl.view.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.amap.api.services.core.PoiItem;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class MapAdressAdapter extends BaseRecycleAdapter<PoiItem> {
    int selsect = 0;

    public MapAdressAdapter(Context context, List<PoiItem> datas) {
        super(context, R.layout.item_map_adress, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, PoiItem poiInfo) {
        holder.setBinding(BR.viewModel, poiInfo);
        ImageView ivSelect = holder.itemView.findViewById(R.id.iv_select);

        if (holder.getAdapterPosition() == selsect) {
            ivSelect.setVisibility(View.VISIBLE);
        } else {
            ivSelect.setVisibility(View.GONE);
        }
    }

    public void setSelsect(int selsect) {
        this.selsect = selsect;
        notifyDataSetChanged();
    }
}
